<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.1</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <style>
      .layui-form-item .layui-form-checkbox[lay-skin=primary]{
          margin-top: 0;
      }
      </style>
  </head>
  
  <body>
    <div class="x-body x-admin">
        <form class="layui-form">
            <input name="id" type="hidden" value="{$pk_cat.id}" />
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>PK组名称
              </label>
              <div class="layui-input-inline">
                  <input type="text"  name="cat_name" value="{$pk_cat.cat_name}" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>必填
              </div>
          </div>
            
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">
                    组内成员
                </label>
                <div class="layui-table-body layui-table-main" style="width: 20%;">
                    <table class="layui-table layui-form">
                        <tbody>
                            {foreach name="adminRes" item="vo"}
                            <tr>
                                <td>
                                    <?php if(!in_array($vo['id'], $admin_Arr)){;?>
                                    <div class="layui-unselect layui-form-checkbox <?php if(in_array($vo['id'], $admin_arr)){ echo 'layui-form-checked';} ?>" lay-skin="primary" data-id="{$vo.id}"><i class="layui-icon">&#xe605;</i></div>
                                    <?php } ;?>
                                    <span class="text">{$vo.name}</span>
                                    <?php if(in_array($vo['id'], $admin_Arr)){;?>
                                    <span style="color:red;float:right;">已在别的组中</span>
                                    <?php } ;?>
                                </td>
                            </tr>
                            {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  确定编辑
              </button>
          </div>
      </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
          $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;

          //监听提交
          form.on('submit(add)', function(data){
            var admins = tableCheck.getData();
            $.ajax({
                type:'POST',
                dataType:'json',
                data:{id:data.field.id,cat_name:data.field.cat_name,admins:admins},
                url:"{:url('PkCat/edit')}",
                success:function(obj){
                  layer.alert(obj.msg, {icon: obj.icon},function(){
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    // 可以对父窗口进行刷新 
                    x_admin_father_reload();
                  });
                }
            });
            return false;
          });
          
          
        });
    </script>
  </body>

</html>